<template>
	<view>
		<!-- 页首 -->
		<zw-header></zw-header>
		<menu-wrapper active-index="2-1" style="background-color: #fff;padding: 0;">
			<view style="display: flex;justify-content: flex-start;align-items: center;margin-top: 25px;">
				<view :class="tabIndex==1?'active':'lable'" @click="clickOption(1)">赞和收藏</view>
				<view style="margin-left: 80rpx;" :class="tabIndex==2?'active':'lable'" @click="clickOption(2)">被关注
				</view>
				<view style="margin-left: 80rpx;" :class="tabIndex==3?'active':'lable'" @click="clickOption(3)">被同款
				</view>
			</view>
			<view class="card-body">
				<view class="container">
					<view style="width: 100%;">
						<view v-for="(item,index) in list" class="item" v-if="tabIndex==2">
							<view style="display: flex;justify-content: flex-start;">
								<view>
									<fui-avatar :src="item.focusUser.avator"></fui-avatar>
								</view>
								<view style="margin-left: 28rpx;">
									<view style="font-size: 32rpx;font-weight: 500;">{{item.focusUser.name}}</view>
									<view style="display: flex;align-items: center;line-height: 60rpx;">关注了你<view>
											{{item.createTime}}
										</view>
									</view>
								</view>
							</view>
							<view>
								<view v-if="!item.focused" style="border-radius: 30rpx;background: #0033FF;color: #FFFFFF;font-size: 16px;padding: 8rpx 30rpx 8rpx 30rpx;">回关
								</view>
								<view v-if="item.focused" style="border-radius: 30rpx;background: #000000;color: #FFFFFF;font-size: 16px;padding: 8rpx 30rpx 8rpx 30rpx;">已关注
								</view>
							</view>
						</view>
						<view v-for="(item,index) in list" class="item" v-if="tabIndex==1">
							<view style="display: flex;justify-content: flex-start;">
								<view>
									<fui-avatar :src="item.pictureCollection.user.avator"></fui-avatar>
								</view>
								<view style="margin-left: 28rpx;">
									<view style="font-size: 32rpx;font-weight: 500;">
										{{item.pictureCollection.user.name}}
									</view>
									<view style="display: flex;align-items: center;line-height: 60rpx;">收藏了你发布的AI作品
									</view>
									<view>{{item.createTime}}</view>
								</view>
							</view>
							<view>
								<view>
									<image style="width: 140rpx;height: 140rpx;border-radius: 14px;"
										:src="item.pictureCollection.formatImages[0]"></image>
								</view>
							</view>
						</view>
					</view>
					<fui-empty isFixed width="200" v-if="list.length==0" height="200" marginTop="400"
						src="../../static/image/user/empty.png" title="暂无数据"></fui-empty>
				</view>
			</view>
		</menu-wrapper>
		<menu-wrapper v-if="list.length>0" active-index="2-1" style="background-color: #fff;padding: 0;margin-top: 40rpx;">
			<view style="display: flex;justify-content: space-between;align-items: center;">
				<view>
					共 4 项数据
				</view>
				<view>
					<fui-pagination :total="1000" custom :pageType="2" :width="60" @change="next" background="#fff"
						activeBgColor="#D000FF">
						<template v-slot:prev>
							<fui-icon :size="40" name="arrowleft" color="#000"></fui-icon>
						</template>
						<template v-slot:next>
							<fui-icon :size="40" name="arrowright" color="#000"></fui-icon>
						</template>
					</fui-pagination>
				</view>
			</view>

		</menu-wrapper>
		<!-- 页脚 -->
		<!-- <zw-footer></zw-footer> -->
	</view>
</template>

<script>
	import menuWrapper from '@/components/user/common/menu-wrapper.vue';
	import centerConfig from '@/common/config/user/center.config.js';

	import {
		mapState
	} from 'vuex';

	export default {
		components: {
			menuWrapper
		},
		data() {
			return {
				...centerConfig,
				accountInfo: {},
				counts: [],
				tabIndex: 1,
				list: [],
			}
		},
		computed: {
			...mapState(['loginUser']),
			currentTime() {
				const currentHour = new Date().getHours();
				const timeQuantums = ['凌晨', '上午', '下午', '晚上'];
				return timeQuantums[Math.floor(currentHour / 6)];
			}
		},
		onLoad(op) {
			this.tabIndex=op.tabIndex;
			this.getList();
			this.$store.commit('tab', 0);
		},
		methods: {
			next(e) {
				this.page = e.current;
				this.getList();
			},
			goUrl(url) {
				uni.navigateTo({
					url: url,
					fail(err) {
						console.log(err)
					}
				})
			},
			clickOption(index) {
				this.tabIndex = index;
				this.page = 0;
				this.list = [];
				this.getList();
			},
			getList() {
				let that = this;
				if (that.tabIndex == 2) {
					this.getFollowList()
				}
				if (that.tabIndex == 1) {
					this.getLoveList()
				}
				if (that.tabIndex == 3) {
					// this.getFollowList()
				}
			},
			getFollowList() {
				let that = this;
				this.$util.request('/api/v1/user/focuslist', {
					size: 100000,
					type: that.tabIndex
				}, (res) => {
					console.log('getFollowList', res)
					that.list = res.data
				}, true);
			},
			getLoveList() {
				let that = this;
				this.$util.request('/api/v1/love', {
					size: 100000,
					queryType: 1,
					type: that.tabIndex
				}, (res) => {
					console.log('getLoveList', res)
					that.list = res.data
					console.log('that.list', that.list)
				}, true);
			}
		}
	}
</script>

<style lang="scss">
	.container {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		width: 100%;

		.item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1px solid #D8D8D8;
			padding-bottom: 20rpx;
			padding-top: 20rpx;
		}
	}

	.lable {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		text-align: center;
		display: flex;
		align-items: center;
		letter-spacing: 0em;

		color: #666666;
	}

	.active {
		font-family: 思源黑体;
		font-size: 36rpx;
		font-weight: bold;
		line-height: normal;
		display: flex;
		align-items: center;
		border-bottom: 6rpx solid #0033FF;
		color: #000000;
		padding-bottom: 10rpx;
	}

	.banner {
		width: 100%;
		height: 200px;
		margin: 0 auto;
		display: flex;
		justify-content: center;
	}

	.avatar {
		width: 100px;
		height: 100px;
		padding: 4px;
		border: 3px solid #FFFFFF;
		border-radius: 100px;
		object-fit: fill;
	}

	.card-header {
		// padding-top: 24px;
		justify-content: space-between;
		@extend %flex-align-center;

		.left {
			@extend %flex-align-center;



			.user-info {
				width: 302px;
				margin-left: 31%;
				// margin-top: -25px;

				.user-name {
					max-width: 220px;
					font-family: Source Han Sans;
					font-size: 24px;
					font-weight: bold;
					font-feature-settings: "kern" on;
					color: #3D3D3D;
				}

				.tip {
					margin-top: 5px;
					font-family: 思源黑体;
					font-size: 12px;
					font-weight: normal;
					line-height: 18px;
					letter-spacing: 0px;
					color: #3D3D3D;
				}

				.link {
					display: inline-block;
					font-size: 12px;
					margin-top: 10px;
					color: $color-primary;
				}
			}
		}

		.right {

			.item {
				@extend %flex-align-center;
				padding: 6px 0;
				margin-left: 66rpx;
				color: #757575;
				display: block;
				text-align: center;

				.value {
					font-family: HarmonyOS Sans SC;
					font-size: 18px;
					font-weight: bold;
					line-height: 35px;
					text-align: center;
					letter-spacing: 0px;
					color: #000000;
				}

				.name {
					font-family: 思源黑体;
					font-size: 12px;
					font-weight: normal;
					line-height: 20px;
					text-align: center;
					letter-spacing: 0px;
					color: #666666;
				}
			}

		}
	}

	.card-body {
		display: flex;
		flex-wrap: wrap;
		margin-top: 10rpx;
		padding-top: 20rpx;
		border-top: 1px solid $border-color;

		.button {
			margin-bottom: 60px;
			@extend %flex-align-center;

			.btn-icon {
				width: 100px;
				height: 100px;
				border-radius: 50%;
			}

			.right {
				width: 276px;
				margin-left: 20px;

				.top {
					@extend %flex-align-center;
					font-size: 18px;
					font-weight: 400;

					.name {
						color: #757575;
					}

					.value {
						color: $color-primary;
					}
				}

				.link {
					line-height: 1.8;
					@extend %flex-align-center;
					color: #757575;
					cursor: pointer;

					&:hover {
						color: $color-primary;
					}

					.icon {
						font-weight: bold;
					}
				}
			}
		}
	}
</style>